<% layout('/layout/default.html', {title: '角色管理', libs: ['dataGrid']}){ %>
<div class="main-content">
		<div class="card-header">
				<i class="fa fa-cubes"></i> 角色管理
			<div class="header-tools float-right">
				<% if(hasPermi('sys:role:edit')){ %>
					<a href="/sys/role/form" class="btn btn-default btn-sm btnTool"  title="新增角色"><i class="fa fa-plus"></i> 新增</a>
				<% } %>
			</div>
		</div>
		<div class="container-fluid">
			<form id="searchForm" action="${ctx}/sys/role/listData" method="post" class="form-inline d-none" >
				<div class="form-group">
					<button type="submit" class="btn btn-success btn-sm ">查询</button>
					<button type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>			
			<table id="dataGrid"></table>
		</div>
</div>
<% } %>
<script>
	$('#dataGrid').dataGrid({
		searchForm: $("#searchForm"),
		columnModel: [
			{header:'角色名称', name:'name', index:'a.name', width:90, align:"center"},
			{header:'英文名称', name:'enname', index:'a.enname', width:140, align:"center"},
			{header:'归属机构', name:'office.name', index:'o.name', width:120, align:"center", formatter: function(val, obj, row, act){
					return row.office.name;
				}},
			{header:'数据范围', name:'dataScope', index:'a.data_scope', width:100, align:"center", formatter: function(val, obj, row, act){
					return js.transDictLabel(${@DictUtils.getDictListJson('sys_data_scope')}, val, '');
				}},
			{header:'操作', name:'actions', width:100, sortable:false, title:false, align:"center", formatter: function(val, obj, row, act){
					var actions = [];
				<% if(hasPermi('sys:role:edit')){ %>

						actions.push('<a href="/sys/role/assign?id='+row.id+'" class="btnList" title="分配用户"><i class="far fa-hand-point-up"></i></a>&nbsp;');
						actions.push('<a href="/sys/role/form?id='+row.id+'" class="btnList" title="编辑角色"><i class="fas fa-pencil-alt"></i></a>&nbsp;');
						actions.push('<a href="${ctx}/sys/role/delete?id='+row.id+'" class="btnList" title="删除角色" data-confirm="确认要删除该角色吗？"><i class="far fa-trash-alt"></i></a>&nbsp;');

					<% } %>

					return actions.join('');
				}}
		],
		// 加载成功后执行事件
		ajaxSuccess: function(data){

		}
	});
</script>